package com.xlq.consultant.controller;

import com.xlq.consultant.aiservice.ConsultantService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@Slf4j
@RestController
public class ChatController {
//    @Resource
//    private OpenAiChatModel openAiChatModel;
    @Resource
    private ConsultantService consultantService;
    @Resource
    private RedisTemplate redisTemplate;

    @RequestMapping(value = "/chat", produces = "text/html;charset=utf-8")// 防止前端乱码
    public Flux<String> chat(String memoryId, String message){
        Flux<String> ans = consultantService.chat(memoryId,message);
        log.info("chatController:{}",ans);
        return ans;
    }

    @GetMapping("/testRedis")
    public void testRedis(){
        redisTemplate.opsForValue().set("test",10);
        return;
    }
}
